package com.itheima.day02.jiekou;

import java.util.ArrayList;

public class CM2 implements A{
    @Override
    public void printallinfo(ArrayList<STUDENT> s) {
        int nanp = 0;
        int nvp = 0;
        System.out.println("——————————全部学生信息如下——————————");
        for (int i = 0; i < s.size(); i++) {
            if(s.get(i).getSex().equals("nv")){
                nvp++;
            }else{
                nanp++;
            }
            System.out.println("姓名："+s.get(i).getName()+
                    "性别："+s.get(i).getSex()+
                    "成绩："+s.get(i).getScore());
        }
        System.out.println("男生人数为："+nanp+"  女生人数为："+nvp);
        System.out.println("_________________________________");
    }


    @Override
    public void printaverage(ArrayList<STUDENT> s) {
        double max = s.get(0).getScore();
        double min = s.get(0).getScore();
        double sum = 0;
        for (int i = 0; i < s.size(); i++) {
            if(s.get(i).getScore()>max){
                max = s.get(i).getScore();
            }
            if(s.get(i).getScore()<min){
                min = s.get(i).getScore();
            }
            sum += s.get(i).getScore();
        }
        System.out.println("去掉一个最高分，去掉一个最低分，平均分为："+(sum-max-min)/(s.size()-2));

    }
}
